package com.asia5b.a5mall.middleware.model.base

import com.google.gson.annotations.SerializedName
import timber.log.Timber

/**
 * Created by zhangyuncai on 2019/6/1.
 */
class ResultModel<T> : ErrorResModel() {
    var data: T? = null

    var isSuccess=true
    get() {
        return ((code == "0")||(code == "200"))
    }
    //当前页数
    @SerializedName(value = "page", alternate = ["page_no"])
    var page = 1
    //每页数量
    @SerializedName(value = "pageSize", alternate = ["page_size"])
    var pageSize = 10
    //总数量
    @SerializedName(value = "totalData", alternate = ["data_total"])
    var totalData = 10000
    var sumPage = 1000
        get() {
            var sum = 1000
            if (pageSize <= 0 || totalData <= 0) {
                sum = 0
            } else {
                if ((totalData % pageSize) == 0) {
                    sum = totalData / pageSize
                } else {
                    sum = totalData / pageSize + 1
                }
            }
            Timber.d(String.format("--->>>>>>>>---page:${page},totalData:${totalData},sum:${sum}"));
            return sum
        }


}